package com.cyy;

/**
 * @author 会玩的洋洋
 * @since 2022-02-22
 */
public class Main {
    public static void main(String[] args) {
        testDoubleCircleLinkedList();
    }

    static void testDoubleCircleLinkedList() {
        DoubleCircleLinkedList<Integer> list = new DoubleCircleLinkedList<>();
        list.add(5);
        list.add(46);
        list.add(34);
        list.add(22);
        list.add(0, 50);
//        System.out.println(list.isEmpty());
//        System.out.println(list);
//        System.out.println(list.contains(22));
//        System.out.println(list.get(3));
//        System.out.println(list.set(3, 26));
//        System.out.println(list.indexOf(22));
//        System.out.println(list.size());
//        System.out.println(list.remove(0));
//        System.out.println(list.remove(2));
//        System.out.println(list.remove(list.size() - 1));
//        System.out.println(list);
//        System.out.println(list.remove(0));
//        System.out.println(list.remove(0));
//        System.out.println(list);

        // 指向头结点（指向1）
        list.reset();

        while (!list.isEmpty()) {
            list.next();
            list.next();
            System.out.println(list.remove());
        }
    }

    static void testSingleCircleLinkedList() {
        List<Integer> list = new SingleCircleLinkedList<>();
        list.add(5);
        list.add(46);
        list.add(34);
        list.add(22);
        list.add(0, 50);
        System.out.println(list.isEmpty());
        System.out.println(list);
        System.out.println(list.contains(22));
        System.out.println(list.get(2));
        System.out.println(list.set(3, 26));
        System.out.println(list.indexOf(22));
        System.out.println(list.size());
        System.out.println(list.remove(0));
        System.out.println(list.remove(2));
        System.out.println(list.remove(list.size() - 1));
        System.out.println(list);
        list.clear();
        System.out.println(list);
    }

    static void testDoubleLinkedList() {
        List<Integer> list = new DoubleLinkedList<>();
        System.out.println(list.isEmpty());
        list.add(5);
        list.add(46);
        list.add(34);
        list.add(22);
        list.add(0, 10);
        System.out.println(list);
        System.out.println(list.contains(22));
        System.out.println(list.get(2));
        System.out.println(list.set(1, 50));
        System.out.println(list.indexOf(22));
        System.out.println(list.size());
        System.out.println(list.remove(0));
        System.out.println(list.remove(list.size() - 1));
        System.out.println(list);
        list.clear();
        System.out.println(list);
    }

    static void testSingleLinkedList() {
        List<Integer> list = new SingleLinkedList<>();
        list.add(5);
        list.add(46);
        list.add(34);
        list.add(22);
        System.out.println(list.contains(22));
        System.out.println(list.get(2));
        System.out.println(list.indexOf(34));
        System.out.println(list.isEmpty());
//        System.out.println(list.set(4, 25));
        System.out.println(list.set(2, 45));
        System.out.println(list.remove(3));
        System.out.println(list.remove(2));
        System.out.println(list.remove(1));
        System.out.println(list.remove(0));
        System.out.println(list.size());
        System.out.println(list);
        list.clear();
        System.out.println(list);
//        System.out.println(list.remove(0));
    }
}
